<#include "/public/macro.html">
<form class="layui-form" id="workOrdersForm" action="/apps/workordersthree/workitem/process.html" method="post" style="width: 100%;height: 100%;">
	<#if workOrders??><input type="hidden" name="id" value="${workOrders.id!''}"></#if>
	<#if workOrders??><input type="hidden" name="dataid" value="${workOrders.id!''}"></#if>
	<#if workOrders??><input type="hidden" name="status" id="status" value="${workOrders.status!''}"></#if>
	<div class="row" style="border-bottom: 1px solid #EFEFEF;">
		<div class="col-lg-12" style="padding-left:0px;position: relative;">
			<div class="ukefu-bt"> 
				<div class="layui-icon ukewo-btn ukefu-content-ind" style="width: 40px;height: 40px;">
					<img src="/images/workorders.png"></div>
				<div class="ukefu-bt-text">
					<div class="ukefu-bt-text-title" style="font-weight:400;font-size:20px;">
						<#if workOrders??>${workOrders.title!''}</#if>
					</div>
					<div class="ukefu-bt-text-content" style="">
						<#if workOrders?? && workOrders.createtime??><span style="font-size:15px;color:#AAAAAA;">工单创建时间：${workOrders.createtime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
						<#if workOrders?? && workOrders.updatetime??><span style="font-size:15px;color:#AAAAAA;margin-left:30px;">最后更新于：${workOrders.updatetime?string('yyyy-MM-dd HH:mm:ss')}</span></#if>
					</div>
				</div>
			</div>
		</div>
	</div>
	<h1 class="site-h1 ukefu-tab" style="border-top:1px solid #e6e6e6;height:26px;">
		<div class="ukefu-tab-title" style="margin-left:0px;">
			<ul class="tab-title" id="workDetailsTab">
				<li class="layui-this"><a href="/apps/workordersthree/workitem/detail.html?id=${workOrders.id!''}" data-toggle="load" data-target="#workordersdetail">工单详情</a></li>
				<li><a href="/apps/workordersthree/detail/dataevent.html?orderid=${workOrders.id!''}" data-toggle="load" data-target="#workOrderContent">变更记录</a></li>
				<li><a href="/apps/workordersthree/detail/comments.html?orderid=${workOrders.id!''}" data-toggle="load" data-target="#workOrderContent">回复记录</a></li>
				<#if workOrders.cusid??>
				<li><a href="/apps/contacts/detail.html?id=${workOrders.cusid!''}" data-toggle="load" data-target="#workOrderContent">联系人信息</a></li>
				</#if>
				<#if workOrderType?? && workOrderType.bpm>
				<li><a href="/apps/bpm/instance/display.html?processid=${workOrders.bpmid!''}&orderid=${workOrders.memo!''}" data-toggle="load" data-target="#workOrderContent">流程信息</a></li>
				</#if>
			</ul>					
		</div>
	</h1>
	
	<div class="row" style="margin-top:5px;">
		<div class="col-lg-12" style="padding-bottom:5px;">
			<div class="row" style="margin-top:5px;">
				<div class="col-lg-12" style="padding-left:0px;line-height:30px;padding-right:0px;">
					<div class="layui-form-item">
					    <div class="layui-input-block">
					    	<input type="radio" name="prirep" value="0" title="公开回复" checked>
				      		<input type="radio" name="prirep" value="1" title="私密回复（只有坐席可见）">
					    </div>
					</div>	
				</div>
			</div>
			<div class="row" style="margin-top:5px;">
				<div class="col-lg-12" style="padding-left:0px;line-height:30px;padding-right:0px;">
					<textarea name="content" id="content" style="width:100%;height:60px;"></textarea>	
				</div>
			</div>
		</div>
	</div>
	<div id="workOrderContent">
		<div class="row" style="border-bottom: 1px solid #EFEFEF;margin-bottom:50px;">
			<div class="col-lg-12" style="padding-left:0px;padding-right:0px;">
				<h1 class="site-h1" style="border-top:1px solid #e6e6e6;margin-top:0px;">
					工单详情
				</h1>
				<#include "/apps/business/workordersthree/include/info.html">
			</div>
		</div>
	
		<div class="row" style="border-bottom: 1px solid #EFEFEF;margin-bottom:100px;">
			<div class="col-lg-12" style="padding-left:0px;padding-right:0px;">
				<h1 class="site-h1" style="border-top:1px solid #e6e6e6;margin-top:15px;">
					工单回复
				</h1>
				
				<div id="ukefu-comments">
					<div class="ukefu-workorders-comment" id="ukefu-workorders-comment">
						<#if orderCommentList?? && orderCommentList.content?size gt 0>
						<#include "/apps/business/workordersthree/comments.html">	
						</#if>
					</div>
				</div>
				
			</div>
		</div>
	</div>
	<div class="layui-form-button" style="width: calc(100% - 320px);">
		<div class="row" style="margin-top:5px;">
			<div class="col-lg-3" style="padding-left:10px;line-height:30px;padding-right:20px;">
				<input type="hidden" name="accdept.text" id="accdept_text">
				<select lay-ignore class="ukefu-select" name="accdept" id="accdept" style="width:100%;" onChange="$('#accdept_text').val($(this).find('option:selected').text());">
					<option value="">请选择部门</option>
					<#if organList??>
					<#list organList as organ>
					<option value="${organ.id!''}" <#if workOrders?? && workOrders.accdept?? && workOrders.accdept == organ.id>selected="selected"</#if>>${organ.name!''}</option>
					</#list>
					</#if> 
				</select>
			</div>
			<div class="col-lg-3" style="padding-left:10px;line-height:30px;padding-right:20px;" id="deptuserdiv">
				<#include "/apps/business/workordersthree/deptuser.html">
			</div>
			<div class="col-lg-3">
				<@select "com.dic.workorders.priority" "priority" workOrders.priority "lay-ignore class=ukefu-select"/>
			</div>
			<div class="col-lg-3" style="padding-right:15px;text-align:right;">
				<div class="layui-btn-group">
					<button class="layui-btn layui-btn-danger" type="submit" lay-filter="formDemo" id="workOrderBtn">提交为  
					<#list uKeFuDic['com.dic.workorders.status'] as workOrdersStatus>
					<#if workOrders.status?? && (workOrders.status == workOrdersStatus.id || workOrders.status == workOrdersStatus.code)>${workOrdersStatus.name!''}</#if>
					</#list>
					</button>
				    <button class="layui-btn layui-btn-danger dropdown-menu" id="ukefu-workorders-status" type="button" style="padding-left:10px;padding-right:10px;"><i class="layui-icon">&#xe619;</i></button>
				    <ul class="ukefu-dropdown-menu layui-anim layui-anim-upbit ukefu-workorders-group" style="right: 0px; left: auto;position: fixed;width:80px;" id="ukefu-workorders-group">
						<li style="border-bottom:1px solid #e6e6e6">
							更新工单状态
						</li>
						<#assign hasclose = false >
						<#list uKeFuDic['com.dic.workorders.status'] as workOrdersStatus>
						<#assign status = workOrdersStatus.id!''>
						<#assign statusname = workOrdersStatus.name!''>
							<#if workOrdersStatus.code?? && workOrdersStatus.code == "uckefu_workorders_closed">
								<#assign hasclose = true >
								<#assign status = "uckefu_workorders_closed">
								<#assign statusname = "已关闭">
						</#if>
						
						<button class="ukefu-submit-btn"  id="batexp"  lay-submit lay-filter="*" ukstatusname='${statusname}' ukstatus='${status}'>
							提交为
							<small class="ukefu-label" <#if workOrdersStatus.iconskin?? && workOrdersStatus.iconskin != "">style="background-color:${workOrdersStatus.iconskin!''};"</#if>>${workOrdersStatus.name!''}</small>
						</button>
						</#list>
						<#if hasclose == false>
						<li>
							<button class="ukefu-submit-btn" id="batexp" lay-submit lay-filter="*" ukstatusname='${statusname}' ukstatus='${status}'>
								提交为
								<small class="ukefu-label" style="background-color:#FF5722;">已关闭</small>
							</button>
						</li>
						</#if>
					</ul>
			    </div>
			</div>
		</div>
	</div>
</form>
<script>
	$(document).ready(function() {
		layui.use('form', function() {
			var form = layui.form;
			form.render(); //更新全部
		});
		$('#workDetailsTab li a').on("click" , function(){
			$('#workDetailsTab li').removeClass("layui-this");
			$(this).parent().addClass("layui-this");
		});
		layui.use(['element', 'flow'], function(){
		  	var element = layui.element ;
		  	var flow = layui.flow;
			flow.load({
			    elem: '#ukefu-comments' //指定列表容器
			   	,scrollElem:".ukefu-col-right"
			    ,done: function(page, next){ //到达临界点（默认滚动触发），触发下一页
			      $.get('/apps/workordersthree/comments.html?orderid=${workOrders.id!''}&p='+page, function(res){
			        //假设你的列表返回在data集合中
			        
			        //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
			        //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
			        next($('#ukefu-workorders-comment').append(res) , $(res).length > 0);    
			      });
			    }
			});
		});
		$(".ukefu-select").select2({minimumResultsForSearch: Infinity});
		$('#accdept').on('select2:select', function (evt) {
			 //选择部门下的 人员
			 loadURL("/apps/workordersthree/dept/user.html?dept="+evt.target.value , "#deptuserdiv");
		});
		KindEditor.ready(function(K) {
			K.create('#content', {
				themeType : 'simple',
				width:"100%",
				resizeType:0,
				uploadJson : "/res/image/upload.html",
				items : ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						 'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
	            allowFileManager : false,
				fontsize:16
			});
		});
		KindEditor.options.cssData = "body { font-size: 15px; font-family:'Microsoft Yahei', 'Helvetica', 'Simsun', 'Arial';}";
		$('#ukefu-workorders-status').on("click" , function(){
			$('#ukefu-workorders-group').css("top" , $(this).offset().top - 15 - $('#ukefu-workorders-group').height() + "px").css("right" ,"9px").show() ;
			var show = false ;
			$('#ukefu-workorders-group').hover(function(){
				show = true ;
			} , function(){
				setTimeout(function(){
					if(!show){
						$('#ukefu-workorders-group').hide();
					}
				} , 1000);
				show = false ;
			}) ; 
		});
	});
</script>